'''
Author: your name
Date: 2021-11-05 14:51:49
LastEditTime: 2021-11-12 11:10:23
LastEditors: Please set LastEditors
Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
FilePath: /tinyms/tinyms-api/apps/cms/site/service.py
'''
from app import db
from .model import Site

class SiteService():
    '''
    删除数据
    '''
    def delete(site_pk):
        site = Site.query.get(site_pk)
        db.session.delete(site)
        db.session.commit()
        
    '''
    保存数据
    '''
    def save(site):
        db.session.add(site)
        db.session.commit()
        
    '''
    更新数据
    '''
    def update(site):
        tmp_site = Site.query.get(site.site_pk)
        tmp_site.site_name = site.site_name
        tmp_site.site_domain = site.site_domain
        tmp_site.site_path = site.site_path
        tmp_site.site_template = site.site_template
        tmp_site.site_time = site.site_time
        tmp_site.site_remarks = site.site_remarks
        tmp_site.site_state = site.site_state
    '''
    分页查询
    '''
    def pages(page):
        pages = Site.query.paginate(int(page), 30, False)
        return pages